package com.pams.controller;

import com.pams.pojo.dto.LoginDTO;
import com.pams.pojo.dto.RegisterDTO;
import com.pams.pojo.vo.LoginVO;
import com.pams.result.Result;
import com.pams.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user")
@Api(tags = "用户管理")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/register")
    public Result<LoginVO> register(@RequestBody RegisterDTO registerDTO) {

        userService.register(registerDTO);
        return Result.success();
    }

   @PostMapping("/login")
    public Result<LoginVO> login(@RequestBody LoginDTO loginDTO) {
     LoginVO loginVO = userService.login(loginDTO);
        return Result.success(loginVO);
    }
}
